furny.furndb.importer
Class FileModelSource

java.lang.Object
  extended by furny.furndb.importer.FileModelSource
All Implemented Interfaces:
IModelSource

public class FileModelSource
extends java.lang.Object
implements IModelSource

Implementation of a model source, that iterates over selected files from a given path.

Since:
26.06.2011
Author:
stephan

Field Summary
private  java.lang.String assetPath
           
private  java.util.List<java.io.File> files
           
private  int index
           
private static java.util.logging.Logger LOGGER
           
 
Constructor Summary
FileModelSource(java.lang.String assetPath, java.util.List<java.io.File> files)
          Creates a new model source, that iterates over selected files from a given path.
 
Method Summary
 int getSize()
          Returns the number of elements.
 boolean hasNext()
          Method to check if more elements are there.
 Furniture next()
          Gets the next element.
 Furniture next(int offset)
          This methods works like next(), but allows to skip elements.
 Furniture previous()
          Gets the previous element.
 void reset()
          Resets and starts at the first element.
 void seek(Furniture furn)
          Seeks the given furniture and remembers its position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

assetPath

private final java.lang.String assetPath

files

private final java.util.List<java.io.File> files

index

private int index
Constructor Detail

FileModelSource

public FileModelSource(java.lang.String assetPath,
                       java.util.List<java.io.File> files)
Creates a new model source, that iterates over selected files from a given path.

Parameters:
assetPath - The path of the files to iterate
files - The files to iterate, must be children of the given path
Since:
26.06.2011
Method Detail

reset

public void reset()
Description copied from interface: IModelSource
Resets and starts at the first element.

Specified by:
reset in interface IModelSource

seek

public void seek(Furniture furn)
Description copied from interface: IModelSource
Seeks the given furniture and remembers its position. A call to next() will give the element after the seeked element.

Specified by:
seek in interface IModelSource
Parameters:
furn - The furniture to seek

hasNext

public boolean hasNext()
Description copied from interface: IModelSource
Method to check if more elements are there.

Specified by:
hasNext in interface IModelSource
Returns:
more elements are left

next

public Furniture next(int offset)
Description copied from interface: IModelSource
This methods works like next(), but allows to skip elements. If the offset is negative, it will return previous elements.

The method works circular, when hasNext() returns false, and the last element is reached, a call to next() will start at the first element.

Specified by:
next in interface IModelSource
Parameters:
offset - The offset of elements
Returns:
the furniture at the desired position

next

public Furniture next()
Description copied from interface: IModelSource
Gets the next element. It simply calls next(1).

Specified by:
next in interface IModelSource
Returns:
the next furniture

previous

public Furniture previous()
Description copied from interface: IModelSource
Gets the previous element. It simply calls next(-1).

Specified by:
previous in interface IModelSource
Returns:
the previous furniture.

getSize

public int getSize()
Description copied from interface: IModelSource
Returns the number of elements.

Specified by:
getSize in interface IModelSource
Returns:
the number of elements.